package Day08.demo4;

import java.io.File;
import java.io.IOException;

/**
 * @author chihb
 * @create-time 2024/7/4 23:46
 * @description
 */
public class Test2 {
    public static void main(String[] args) throws IOException {
        searchFile(new File("C:/"),"QQ.exe");
    }
    public static void searchFile(File dir, String filename) throws IOException {
        if(dir==null || !dir.exists() || dir.isFile()){
            return;
        }
        File[] files = dir.listFiles();
        if(files!=null&&files.length>0){
            for (File f: files){
                if(f.isFile()){
                    if(f.getName().contains(filename)){
                        System.out.println(f.getAbsolutePath());
                        Runtime runtime=Runtime.getRuntime();
                        runtime.exec(f.getAbsolutePath());
                    }
                }else {
                    searchFile(f,filename);
                }
            }
        }
    }
}
